home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d7
/
lanperf.arc
/
LPTEST.ASM
< prev
next >
Wrap
Assembly Source File
|
1988-06-04
|
7KB
|
346 lines
TITLE LPTEST ASM routines -- Version 1.00
NAME LPTEST
public _lpstart
public _rtest
public _wtest
MAXBLK = 8192 ; needs to match with MAXBLK in LANPERF.C
;
; Values for DOS function calls (int 21h)
;
CONIO = 06h
CONCHK = 0Bh
CREATE = 3Ch
OPEN = 3Dh
O_RD = 0
O_WR = 1
O_RW = 2
CLOSE = 3Eh
READ = 3Fh
WRITE = 40h
DELETE = 41h
SEEK = 42h
CHMOD = 43h
MKTEMP = 5Ah
_DATA SEGMENT word public 'DATA'
;
; Data shared with LANPERF.C, the main driver program
;
extrn _master:word ; set if we started the test
extrn _blksize:word ; block size (bytes)
extrn _ioshare:byte ; file sharing mode
extrn _iobuf:byte ; I/O buffer
extrn _duration:word ; length of test (seconds)
extrn _ops:word ; (long) number of operations performed
extrn _filesize:word ; size of file (blksize blocks)
extrn _fname:byte ; file name buffer
;
; Local data
;
endtime dw 0,0 ; test ending time (ticks)
n_blks dw 0 ; number of blocks before re-seek
iopos dw 0 ; write position in _iobuf
_DATA ENDS
LOWMEM segment at 0
org 046Ch
clock dw ?,? ; BIOS clock value
LOWMEM ends
;
; GTICKS - macro to load BIOS tick count
; (assumes ES is set to LOWMEM)
;
GTICKS macro LOREG,HIREG
cli
mov LOREG,es:[clock]
mov HIREG,es:[clock+2]
sti
endm
_TEXT segment byte public 'CODE'
DGROUP group _DATA
assume CS:_TEXT, DS:DGROUP, ES:LOWMEM
;
; lpmark - wait for key press or creation of start file
;
; Return: 0 for "test has started"; DOS error code otherwise
; Sets _master to 1 if we started the test, else 0
;
_lpstart proc near
mov [_master],0 ; assume we didn't start
retry: mov ah,CONCHK ; check for a char a few times
int 21h
or al,al
jnz gotch
mov ah,CONCHK
int 21h
or al,al
jnz gotch
mov ah,CONCHK
int 21h
or al,al
jnz gotch
mov ah,CHMOD ; see if trigger file is there
mov al,0
lea dx,_fname
int 21h
jc retry
jmp short mkok
gotch: mov dl,0FFh
mov ah,CONIO ; flush out the char we got
int 21h
mov ah,CONIO ; catch extended ascii chars
int 21h
mov [_master],1 ; we started the test
mov ah,CREATE ; make the trigger file
xor cx,cx
lea dx,_fname
int 21h
jc mkerr
mov bx,ax
mov ah,CLOSE
int 21h
jc mkerr
mkok: xor ax,ax ; signal success
mkerr: ret
_lpstart endp
;
; _rtest - LANPERF sequential read test
;
; Creates a file of (_blksize * _filesize) bytes, then reads
; it sequentially. The file is rewound when EOF is reached.
;
_rtest proc near
push es
xor ax,ax ; point es to LOWMEM
mov es,ax
mov ah,MKTEMP ; create temp file
xor cx,cx ; normal attributes (read/write)
lea bx,_fname ; address of file name buffer
mov [bx],ch ; (must be null terminated)
mov dx,bx
int 21h
jnc rok
jmp rnopen
rok: mov bx,ax ; put handle in bx
call finit ; fill file with data
jc rerror
mov ah,CLOSE ; close the temp file
int 21h
jc rerror
mov ah,OPEN ; re-open file with the
mov al,[_ioshare] ; desired sharing mode
lea dx,_fname
int 21h
jc rerror
mov bx,ax ; put handle in bx
xor ax,ax ; zero out op count
mov [_ops],ax ;
mov [_ops+2],ax ;
mov ax,[_filesize] ; initialize block count
mov [n_blks],ax ;
push bx ; save handle
call clkon ; figure out ending time
pop bx ; put handle in bx for loop
rloop:
mov cx,[_blksize] ; block size to be read
lea dx,_iobuf ; buffer address
mov ah,READ ; read a block
int 21h
jc rerror
cmp ax,cx ; I/O not completed,
jne rbadio ; real trouble is brewing
add [_ops],1 ; rack up another operation
adc [_ops+2],0 ;
dec [n_blks] ; need to re-start at BOF?
jnz rnseek
mov ah,SEEK ; yes
xor cx,cx
mov al,cl
mov dx,cx
int 21h
jc rerror
mov ax,[_filesize] ; reset count
mov [n_blks],ax
rnseek: GTICKS ax,dx ; get current time
sub ax,[endtime] ; subtract ending time
sbb dx,[endtime+2]
jb rloop ; keep going until past endtime
xor ax,ax ; zero means successful
jmp rexit
rbadio: mov ax,-1 ; not all bytes read/written
rerror: ; errors have ax set to DOS err code
rexit: push ax
mov ah,CLOSE ; close the file (bx has handle)
int 21h
mov ah,DELETE ; delete the file
lea dx,_fname
int 21h
pop ax
rnopen: pop es
ret
_rtest endp
;
; _wtest - LANPERF sequential write test
;
; Sequentially writes a file of (_blksize * _filesize) bytes.
; The file is rewound when the desired file size is reached.
; To defeat cacheing schemes that recognize and ignore repeated
; writes of the same data, the data is changed on each write.
;
_wtest proc near
push es
xor ax,ax ; point es to LOWMEM
mov es,ax
mov ah,MKTEMP ; create temp file
xor cx,cx ; normal attributes (read/write)
lea bx,_fname ; address of file name buffer
mov [bx],ch ; (must be null terminated)
mov dx,bx
int 21h
jnc wok
jmp wnopen
wok: mov bx,ax
mov ah,CLOSE ; close the file
int 21h
jnc wner
jmp werror
wner: mov ah,OPEN ; open file with
mov al,[_ioshare] ; sharing mode from cmd line
or al,O_RW ; read/write access
lea dx,_fname
int 21h
jc werror
mov bx,ax ; handle in bx
xor ax,ax ; zero out op count
mov [_ops],ax ;
mov [_ops+2],ax ;
mov ax,[_filesize] ; initialize block count
mov [n_blks],ax ;
push bx ; save handle
call clkon ; figure out ending time
pop bx ; put handle in bx for loop
mov [iopos],offset _iobuf-1
wloop:
mov dx,[iopos] ; change position in _iobuf
inc dx ; to vary the data pattern
cmp dx,offset _iobuf+MAXBLK
jb wrtblk
lea dx,_iobuf
wrtblk: mov [iopos],dx
mov cx,[_blksize] ; block size to be written
mov ah,WRITE ; perform write
int 21h
jc werror
cmp ax,cx ; I/O not completed,
jne wbadio ; real trouble is brewing
add [_ops],1 ; rack up another operation
adc [_ops+2],0 ;
dec [n_blks] ; need to re-start at BOF?
jnz wnseek
mov ah,SEEK ; yes
xor cx,cx
mov al,cl
mov dx,cx
int 21h
jc werror
mov ax,[_filesize] ; reset count
mov [n_blks],ax
wnseek: GTICKS ax,dx ; get current time
sub ax,[endtime] ; subtract ending time
sbb dx,[endtime+2]
jb wloop ; keep going until past endtime
xor ax,ax ; zero means successful
jmp wexit
wbadio: mov ax,-2 ; not all bytes written
werror: ; errors have ax set to DOS err code
wexit: push ax
mov ah,CLOSE ; close the file (bx has handle)
int 21h
mov ah,DELETE ; delete the file
lea dx,_fname
int 21h
pop ax
wnopen: pop es
ret
_wtest endp
;
; finit - initialize file with data for reading
;
finit proc near ; bx has file handle
mov cx,[_blksize]
lea dx,_iobuf
mov ax,[_filesize]
mov [n_blks],ax
rbuild:
mov ah,WRITE
int 21h
jc ferror
dec [n_blks]
jnz rbuild
mov ah,SEEK ; seek to beginning of file
xor cx,cx
mov al,cl
mov dx,cx
int 21h
ferror: ret
finit endp
;
; clkon - calculate test endtime from duration
;
; NOTE: This routine fails if midnight is crossed
;
clkon proc near
mov ax,[_duration] ; get run time in seconds
xor dx,dx ; convert to ticks, .2 seconds first
mov cx,5
div cx
mov bx,ax
mov ax,[_duration]
mov cx,18 ; now the 18 seconds part
mul cx
add ax,bx
adc dx,0 ; duration (in ticks) now in ax:dx
mov [endtime],ax
mov [endtime+2],dx
GTICKS ax,dx ; get current time in ticks
add [endtime],ax ; add to duration
adc [endtime+2],dx
ret
clkon endp
_TEXT ENDS
END